
<div class="xinxi-guanli">
<div class="xinxi-title">
	
	<ul id="details-ul" class="clearfix">
		<li class="hover"><a href="/company/index">企业资料</a></li>
		<li><a href="/company/password">修改密码</a></li>
		<!--
		<li><a href="/company/auth">授权管理</a></li>
		-->
	</ul>
</div>
 <div id="details-con-1" class="xinxi-guanli-box">
<form id="applyform" action="" method="post" onsubmit="return addContent();">
<table class="grinfo">
  <tbody>

	<tr>
		<th><span class="red">*</span>行业分类：</th>
		<td colspan="2">
		<select id="catid" class="inp inw" style="width:85px;" name="catid">
		{$Categoryhtml}
		</select>
		<span id="typeidhtml">
		<select id="sontypeid" class="inp inw" style="width:105px;" name="typeid">
			{$SonCategoryhtml}
		</select>
		</span>
		<span id="catidhtml" class="fgrey"></span>
		</td>
	</tr>

	<tr>
		<th><span class="red">*</span>企业所在地区：</th>
		<td colspan="2">
		<select id="province" class="inp inw" style="width:140px;" name="province">
		{$Areahtml}
		</select>
		<span id="cityhtml">
		<select id="city" class="inp inw" style="width:100px;" name="city">
		{$SonAreahtml}
		</select>
		</span>
		<span id="provincehtml" class="fgrey"></span>
		</td>
	</tr>
	
	
	<tr>
		<th><span class="red">*</span> 企业名称：</th>
		<td>
		<input type="text" value="{$data.MemberCompany.company}" id="company" name="company"  style="width:400px;" class="inp inw">
		<input type="hidden" name="userid"  value="{$data.userid}" >
		</td>
	</tr>

	<tr>
		<th><span class="red">*</span> 企业地址：</th>
		<td>
		<input type="text" value="{$data.MemberCompany.address}" id="address" name="address"  style="width:400px;" class="inp inw"></td>
	</tr>

	



	<tr>
		<th><span class="red">*</span>企业法人：</th>
		<td colspan="2">
			<input type="text" name="corporate" id="corporate" style="width:120px;" value="{$data.MemberCompany.corporate}" class="inp inw"> <span id="corporatehtml" class="fgrey">企业法人姓名</span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="red">*</span><span style="font-size:14px">企业联系人：</span>
			<input type="text" name="contact" id="contact" style="width:120px;" value="{$data.MemberCompany.contact}" class="inp inw" > <span id="contacthtml"  class="fgrey">企业负责人姓名</span>
		</td>
	</tr>


	<tr>
		<th><span class="red">*</span>业务手机号：</th>
		<td colspan="2">
			<input type="text" name="mobilenum" id="mobilenum" style="width:100px;" maxlength="11"  value="{$data.MemberCompany.mobilenum}" class="inp inw"> <span id="mobilenumhtml" class="fgrey">业务员的手机号码</span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="red">*</span><span style="font-size:14px">业务电话：</span>
			<input type="text" name="telephone" id="telephone" style="width:150px;" value="{$data.MemberCompany.telephone}" class="inp inw" > <span id="telephonehtml"  class="fgrey" maxlength="14" >例：010-87654321</span>


		</td>
	</tr>

	
	<tr>
		<th valign="top"><span class="red">*</span>主要经营产品：</th>
		<td>
			<textarea name="product" class="grtextarea" id="product" style="width:600px;height:100px;" >{$data.MemberCompany.product}</textarea>
			<br>
			<span class="fgrey" id="producthtml">请填写企业主要的业务方向,200字以内为宜</span>
		</td>
	</tr>


	<tr>
		<th valign="top"><span class="red">*</span>企业简介：</th>
		<td>
			<textarea name="introduction" class="grtextarea" style="width:505px;height:280px;" id="introduction">{$data.MemberCompany.introduction}</textarea>
			<span id="introductionhtml" class="fgrey"><span class="red">*</span>&nbsp;&nbsp;企业简介不能少于150个字。
温馨提示：为保证您发布内容格式的正确，请直接在编辑窗口中进行编辑，不要直接粘贴从word里复制的内容！</span>
		</td>
	</tr>


	<tr>
		<th>企业英文名：</th>
		<td>
		<input type="text" value="{$data.MemberCompany.ecompany}" id="ecompany" name="ecompany" style="width:480px;" class="inp inw"></td>
	</tr>

	<tr>
		<th>企业网站：</th>
		<td>
		<input type="text" value="{$data.MemberCompany.homepage}" id="homepage" name="homepage" style="width:480px;" class="inp inw"></td>
	</tr>

	<tr>
		<th>成立时间：</th>
		<td colspan="2">
			<input type="text" name="found" id="found" style="width:50px;" maxlength="4" value="{$data.MemberCompany.found}" class="inp inw"> <span id="foundhtml" class="fgrey">例如:2001</span>&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size:14px">注册资本：</span>
			<input type="text" name="turnover" id="turnover" style="width:50px;" maxlength="10" value="{$data.MemberCompany.turnover}" class="inp inw" > <span id="turnoverhtml"  class="fgrey">(单位:万)</span>

			&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size:14px">员工数：</span>
			<input type="text" name="employee" id="employee" style="width:50px;" maxlength="8"  value="{$data.MemberCompany.employee}" class="inp inw" > <span id="employeehtml"  class="fgrey">(单位:人)</span>

		</td>
	</tr>

	<tr>
		<th>&nbsp;</th>
		<td colspan="2">
			<label id="butt" class="butt">
				<input type="submit" name="btnSubmit" value="完成修改" id="btnSubmit" class="btns">
			</label>
		</td>
	</tr>
</tbody>
</table>
</form>

  </div>
  
    
</div>

<script type="text/javascript" src="/public/js/plugin/jquery.uploadify-3.1.min.js"></script>
<script type="text/javascript" src="/public/js/plugin/tinymce/tinymce.min.js"></script>
<script type="text/javascript" src="/public/js/plugin/layer/jquery.layer.js"></script>
<script type="text/javascript" src="/public/js/plugin/jquery.form.js"></script>
<script type="text/javascript" src="/public/js/plugin/jquery.validate.js"></script>
<script type="text/javascript" src="/public/js/product.js"></script>
<script type="text/javascript">
function addContent()
{
	var content = tinyMCE.get('introduction').getContent();
    $("#introduction").val(content);
}

//选取文件的函数，后台特有
tinymce.init({
    selector: "textarea#introduction",
    theme: "modern",
	language :"zh_CN",
    width: 600,
    height: 300,
    plugins: [
         "advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker",
         "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
         "save table contextmenu directionality emoticons template paste textcolor"
   ],
   content_css: "css/content.css",
   toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | l      ink image | print preview media fullpage | forecolor backcolor emoticons", 
   style_formats: [
        {title: 'Bold text', inline: 'b'},
        {title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
        {title: 'Red header', block: 'h1', styles: {color: '#ff0000'}},
        {title: 'Example 1', inline: 'span', classes: 'example1'},
        {title: 'Example 2', inline: 'span', classes: 'example2'},
        {title: 'Table styles'},
        {title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
    ]
 });   

$(document).ready(function(){
	
	

	$("#catid").bind("change", function(){
		var pid = $(this).val();
		
		$.post('/ajax/category',{pid:pid},function(result){
			$("#typeidhtml").html(result.data);
		});
	});

	$("#province").bind("change", function(){
		var pid = $(this).val();
		
		$.post('/ajax/area',{pid:pid},function(result){
			$("#cityhtml").html(result.data);
		});
	});

		$("#unit").bind("change", function(){
		var unit = $(this).val();
		if(unit>0){
			$("#unithtml").hide();
		}else{
			$("#unithtml").show();
		}
		
	});



	$("#applyform").validate({
	  		focusInvalid: true ,
			errorClass: "err_ipt",
			ignore: "",
			rules: { 
				
				'catid': {
	                required: true,
					digits: true
	            },
	            'typeid': {
	                required: true,
					digits: true
	            },
				'province': {
	                required: true,
					digits: true
	            },
	            'city': {
	                required: true,
					digits: true
	            },
				
				'company':{
					required: true,
					minlength:5
				}, 
				'address': {
					required: true,
					minlength:5
	            },
				'corporate': {
					required: true,
					chinese: true,
					minlength:2
	            },
				'contact': {
					required: true,
					chinese: true,
					minlength:2
	            },
	            'mobilenum': {   
	                required: true,
					digits: true,
					minlength:11,
					maxlength:11
	            },
				'telephone': {   
	                required: true,
					phone: true
	            },
				'product':{
					required: true,
					minlength:20
				}, 
				'introduction':{
					required: true,
					minlength:50
				}, 
				'found':{
					digits: true,
					minlength:4,
					maxlength:4
				}, 
				'turnover':{
					digits: true,
					minlength:1,
					maxlength:10
				}, 
				'employee':{
					digits: true,
					minlength:1,
					maxlength:8
				}
	        },   
	        messages: {
				'catid': {
					required: '<span class="fgrey"><img src="/public/images/error.gif" />&nbsp; 请选择产品大分类.</span>',
					digits: '<span class="fgrey"><img src="/public/images/error.gif" />&nbsp; 请选择产品大分类.</span>'
				},
				'typeid': {
					required: '<span class="fgrey"><img src="/public/images/error.gif" />&nbsp; 请选择产品小分类.</span>',
					digits: '<span class="fgrey"><img src="/public/images/error.gif" />&nbsp; 请选择产品小分类.</span>'
				},
				'province': {
					required: '<span class="fgrey"><img src="/public/images/error.gif" />&nbsp; 请选择地区.</span>',
					digits: '<span class="fgrey"><img src="/public/images/error.gif" />&nbsp; 请选择地区.</span>'
				},
				'city': {
					required: '<span class="fgrey"><img src="/public/images/error.gif" />&nbsp; 请选择省市.</span>',
					digits: '<span class="fgrey"><img src="/public/images/error.gif" />&nbsp; 请选择省市.</span>'
				},
	        	'company':{
	        		required:'<span class="fgrey"><img src="/public/images/error.gif" />&nbsp;例如:都市家(北京)建材有限企业.</span>',
	        		minlength: jQuery.format('<span class="fgrey"><img src="/public/images/error.gif" />&nbsp; 企业名称不得少于{0}个字.</span>')
	            },
	            'address': {
	            	required:'<span class="fgrey"><img src="/public/images/error.gif" />&nbsp; 请填写企业地址</span>',
	            	minlength:'<span class="fgrey"><img src="/public/images/error.gif" />&nbsp; 企业地址不得少于{0}个字.</span>'
				},
				 'corporate': {
	            	required:'<span class="fgrey"><img src="/public/images/error.gif" />&nbsp;必填项.企业法人姓名</span>',
					chinese:'<span class="fgrey"><img src="/public/images/error.gif" />&nbsp;姓名必须是中文字</span>',
	            	minlength:'<span class="fgrey"><img src="/public/images/error.gif" />&nbsp;企业法人不得少于{0}个字.</span>'
				},
				'contact': {
	            	required:'<span class="fgrey"><img src="/public/images/error.gif" />&nbsp; 请填写企业联系人</span>',
					chinese:'<span class="fgrey"><img src="/public/images/error.gif" />&nbsp;姓名必须是中文字</span>',
	            	minlength:'<span class="fgrey"><img src="/public/images/error.gif" />&nbsp;企业联系人不得少于{0}个字.</span>'
				},
				'mobilenum': {
					required: '<span class="fgrey"><img src="/public/images/error.gif" />&nbsp; 必填项.</span>',
					digits: '<span class="fgrey"><img src="/public/images/error.gif" />&nbsp;只能填写数字.</span>',
					minlength:'<span class="fgrey"><img src="/public/images/error.gif" />&nbsp;手机号不得少于{0}个字.</span>',
					maxlength:'<span class="fgrey"><img src="/public/images/error.gif" />&nbsp;手机号不得多于{0}个字.</span>'
				},
				'telephone': {
					required: '<span class="fgrey"><img src="/public/images/error.gif" />&nbsp;必填项.例：010-87654321.</span>',
					phone: '<span class="fgrey"><img src="/public/images/error.gif" />&nbsp;例：010-87654321.</span>'
				},
				'product':{
	        		required:'<span class="fgrey"><img src="/public/images/error.gif" />&nbsp;企业主要的业务方向说明必须填写.</span>',
	        		minlength: jQuery.format('<span class="fgrey"><img src="/public/images/error.gif" />&nbsp;企业主要的业务方向说明，不能少于{0}个字.</span>')
	            },
				'introduction':{
	        		required:'<span class="fgrey"><img src="/public/images/error.gif" />&nbsp; 企业简介不能少于150个字。温馨提示：为保证您发布内容格式的正确，请直接在编辑窗口中进行编辑，不要直接粘贴从word里复制的内容！.</span>',
	        		minlength: jQuery.format('<span class="fgrey"><img src="/public/images/error.gif" />&nbsp; 企业简介信息不得少于{0}个字.</span>')
	            },
				'found': {
					digits: '<span class="fgrey"><img src="/public/images/error.gif" />&nbsp;只能填写数字.</span>',
					minlength:'<span class="fgrey"><img src="/public/images/error.gif" />&nbsp;只能{0}位数字.</span>',
					maxlength:'<span class="fgrey"><img src="/public/images/error.gif" />&nbsp;只能{0}位数字.</span>'
				},
				'turnover': {
					digits: '<span class="fgrey"><img src="/public/images/error.gif" />&nbsp;只能填写数字.</span>',
					minlength:'<span class="fgrey"><img src="/public/images/error.gif" />&nbsp;不得少于{0}位数字.</span>',
					maxlength:'<span class="fgrey"><img src="/public/images/error.gif" />&nbsp;不得多于{0}位数字.</span>'
				},
				'employee': {
					digits: '<span class="fgrey"><img src="/public/images/error.gif" />&nbsp;只能填写数字.</span>',
					minlength:'<span class="fgrey"><img src="/public/images/error.gif" />&nbsp;不得少于{0}位数字.</span>',
					maxlength:'<span class="fgrey"><img src="/public/images/error.gif" />&nbsp;不得多于{0}位数字.</span>'
				}
				
			},
			errorPlacement: function(error, element) {
				
				if ($(element).attr("name")=='catid') {
					if(parseInt($("#catid").val())==0){
						$("#catidhtml").html(error);
						return true;
					}
		        }

				if ($(element).attr("name")=='typeid') {
					if(parseInt($("#sontypeid").val())==0){
						$("#catidhtml").html(error);
						return true;
					}
		        }

				if ($(element).attr("name")=='province') {
					if(parseInt($("#province").val())==0){
						$("#provincehtml").html(error);
						return true;
					}
		        }

				if ($(element).attr("name")=='city') {
					if(parseInt($("#city").val())==0){
						$("#provincehtml").html(error);
						return true;
					}
		        }
				
				if ($(element).attr("name")=='corporate') {
		        	$("#corporatehtml").html(error);
		            return true;
		        }

				if ($(element).attr("name")=='contact'){
					$("#contacthtml").html(error);
		            return true;
				}

				if ($(element).attr("name")=='cycle') {
		        	$("#cyclehtml").html(error);
		            return true;
		        }

				if ($(element).attr("name")=='mobilenum') {
		        	$("#mobilenumhtml").html(error);
		            return true;
		        }

				if ($(element).attr("name")=='telephone') {
		        	$("#telephonehtml").html(error);
		            return true;
		        }

				if ($(element).attr("name")=='product'){
					$("#producthtml").html(error);
					return true;
				}
				
				if ($(element).attr("name")=='introduction') {
		        	tinyMCE.get('introduction').focus();
					$("#introductionhtml").html(error);
					return true;
		        }

				if ($(element).attr("name")=='found') {
		        	$("#foundhtml").html(error);
		            return true;
		        }

				if ($(element).attr("name")=='turnover') {
		        	$("#turnoverhtml").html(error);
		            return true;
		        }

				if ($(element).attr("name")=='employee') {
		        	$("#employeehtml").html(error);
		            return true;
		        }
		        
		        error.insertAfter(element);
		    },
			success: function(label) {
				label.html('<span class="f_prompt"><img src="/public/images/yes.gif" /></span>').addClass("success");
			},
			submitHandler: function(form) {
				
				jQuery(form).ajaxSubmit({
					target: "#result",
					beforeSubmit:disableForm,
			        success:submitForm, 
			        url:'/company/index',       
			        type:'post',      
			        dataType:'json'
				});
			}
		});
	  	function disableForm(){
			$('#applyform').find("input[type='submit']").attr("disabled",true);
			$('#applyform').find("input[type='submit']").val("正在修改,请稍等...");
			$.layer({
				v_title:'发布中',
				v_btns:0,
				v_msgtype:0,
				v_shade:false,
				v_area : ['300px','150px'],
				v_msg:'<div class="">\
							<div class="">\
							   <font color="green">数据正在提交到服务器进行发布,<br/>请耐心等待...</font>\
							</div>\
						</div>'
			});
			return true; 
		}

		function submitForm(responseText)  { 
			layer_close(true);
			if(responseText.status){
				if(responseText.data.id){
					$.layer({
						v_msg:responseText.info,
						v_title:'修改信息成功',
						v_btns:2,
						v_shade:false,
						v_btn:['查看资料','继续修改'],
						v_area:['410px','220px'],
						yes:function(){
							layer_close(true);
							location.href ="/company/index";
						},
						no:function(){
							location.href = '/company/index';
						}
					});
				}else{
					$.layer({v_msg:responseText.info,v_shade:false,v_title:'修改资料出错',v_showtime:2});
				}
				
			}else{
				
				$.layer({v_msg:responseText.info,v_shade:false,v_title:'修改资料出错',v_showtime:2});

				if(responseText.data.inputName == 'introduction'){
					tinyMCE.get('introduction').focus();
				}else{
					$("#"+responseText.data.inputName).focus();
				}
				$('#applyform').find("input[type='submit']").attr("disabled",false);
				$('#applyform').find("input[type='submit']").val("完成修改");
			}
		}


		
 });	
 </script>